/*
 * @Description: 最多出现次数
 * @Author: zzj
 * @Date: 2021-09-09 14:26:32
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-09 20:42:41
 */

//封装一个函数，给定一个字符串，输出出现最多次的那个字符和索引。

const readline = require("readline-sync");
var str = readline.question("请输入字符串：");
//var str = "xiongmaoshiguobaooxxxx";
var arr1 = [];
var arr2 = [1];
arr1.push(str[0]);
var num1 =[];
var num2 = 0;
function zdcs(str){
    for(var k=1;k<str.length;k++){
        var num1=arr1.length;
        for(var i=0;i<num1;i++){
            if(arr1[i]==str[k]){
                arr2[i]=arr2[i]+1;
                break;
            }
            if(i==num1-1){
                arr1.push(str[k]);
                arr2.push(1);
            }
        }      
    }
    //console.log(arr1,arr2,num1);

    var n = Math.max(...arr2);
    for (s in arr2){
        if(arr2[s] == n){
            console.log("出现次数最多的字符为" + arr1[s]);
            console.log("出现的次数为" + n);
            for (t in str){
                if(arr1[s] == str[t]){
                    console.log("该字符的出现位置为" + t);
                }
            }
            console.log(" ");
        }else{
            continue;
        }
    }   
 }
 zdcs(str);